package com.py.credit.clean.code;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang3.StringUtils;

public class RequiredDateStyleCheck
{
    /**
     * 日期不得为空 并且格式合法
     * @param data
     * @param extend
     * @return
     */
    public boolean run(String data,String extend){
        if(StringUtils.isBlank(data)){
            return false;
        }
        Pattern p = Pattern.compile(extend);
        Matcher m = p.matcher(data.replace("/", "-"));
        boolean dateFlag = m.matches();
        if(!dateFlag){
            return false;
        }
        
        return true;
    }
    
     public static void main(String[] args)
    {
        RequiredDateStyleCheck rdc=new RequiredDateStyleCheck();
        System.out.println(rdc.run("1934/02/11", "^(19[0-9]{2}|20[0-9]{2})-(((0[13578]|(10|12))-(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30)))$"));
    }
     
    
}
